package cn.ubeta.b2c.user.address;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import cn.ubeta.b2c.R;
import cn.ubeta.b2c.common.AnalyseActivity;
import cn.ubeta.b2c.common.LoginCommon;
import cn.ubeta.b2c.utils.Constants;

/**
 * Created by denny on 16/9/5.
 */

public class AddressActivity extends AnalyseActivity {

    private Fragment mFragment;

    @Override
    public String getPageName() {
        return "地址列表页";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_address);

        //TitleBarHelper.setRightAction(this, "添加", v -> EditAddressActivity.gotoAddressEdit(this, 0));

        mFragment = AddressFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fl_fragment, mFragment)
                .commit();
    }

    /**
     * 跳转地址列表
     * @param activity
     */
    public static void gotoAddressList(Activity activity) {
        if (LoginCommon.isLogin()) {
            Intent intent = new Intent(activity, AddressActivity.class);
            activity.startActivityForResult(intent, Constants.REQ_CODE_ADDRESS);
        } else {
            LoginCommon.gotoLogin(activity);
        }
    }
}
